# ! <<< Self
# ! >>>
import sys
import os

sys.path.append("..")
import segEvaluation_Func as eva
from paraClass import NormParas, PreParas, KerasParas

os.environ["CUDA_VISIBLE_DEVICES"] = "0"

organ = 'RatBrain'
stage = 'val'

# ! <<< Path
txtpath = '/home/yusongli/Documents/shidaoai_new_project/networks/2D-Unet/_conf/val.txt'
savepath = os.path.join(
    '/home/yusongli/_dataset/shidaoai/img/_out',
    '2dunet/20220708'
)

# ! >>>

"""Not change the following parameters"""
normparas = NormParas()
normparas.method = "minmax"
normparas.lmin = 0
# ! <<< Self parameters
# normparas.rmax = 2000
normparas.rmax = 1500
# ! >>>

preparas = PreParas()
# ! <<< Self parameters
# preparas.patchdims = [1, 128, 128]
# preparas.patchlabeldims = [1, 128, 128]
# preparas.patchstrides = [1, 32, 32]
# preparas.patchstrides = [1, 48, 48]
preparas.patchdims = [1, 16, 16]
preparas.patchlabeldims = [1, 16, 16]
preparas.patchstrides = [1, 16, 16]
# ! >>>

preparas.organname = organ
preparas.stage = stage
preparas.nclass = 2
preparas.ndim = '2D_LabelHot'
preparas.issubtract = 0

kerasparas = KerasParas()
kerasparas.outID = 0
kerasparas.thd = 0.5
kerasparas.loss = 'dice_coef_loss'
organids = [1]

kerasparas.imgformat = 'channels_last'
kerasparas.modelname = '2D_Unet'
"""------------------------------------"""

modelpath = os.path.join(
    '/home/yusongli/_dataset/shidaoai/img/_out',
    '2dunet',
    '20220708/GTV-T-2D_Unet-86-0.5969-0.6302.hdf5'
)
kerasparas.modelpath = modelpath

# eva.online_seg_evaluation(imgpath,labelpath,savepath,preparas,normparas,organids,kerasparas)
eva.online_seg_prediction(txtpath, savepath, preparas, normparas, kerasparas)

